home *** CD-ROM | disk | FTP | other *** search
- Path: digex.net!not-for-mail
- From: igor@access4.digex.net (Dan White)
- Newsgroups: comp.lang.c
- Subject: Re: STRTOL, STRTUL,STRTOD functions
- Date: 22 Mar 1996 21:30:37 -0500
- Organization: Society for the Prevention of Paronomastic Defenestration
- Message-ID: <4ivnod$afn@access4.digex.net>
- References: <4ifjao$j5c@news1.h1.usa.pipeline.com> <314ed2d3.110217@news.fred.net>
- NNTP-Posting-Host: access4.digex.net
-
- In article <314ed2d3.110217@news.fred.net>,
- Scott Allen <bitmask@bigdog.fred.net> wrote:
- >fredrics@usa.pipeline.com(Fredric Smith) wrote:
- >
- >>I cannot find sample pieces of code for these..would appreciate some
- >>help..if someone can
- >>
- >
- >int main(void)
- >{
- > char *string = "87654321", *endptr;
- > long lnumber;
- >
- > /* strtol converts string to long integer */
- > /* strtoul converts a string to an unsigned long */
- > /* strtod converts a string to a double */
- >
- > /* *endptr will point to the character that stopped the scan */
- >
- >
- > lnumber = strtol(string, &endptr, 10);
- >
- > printf("string = %s long = %ld\n", string, lnumber);
- >
- > return 0;
- >}
- >
- >
- >Hope this helps,
-
- ...and what is wrong with using sscanf ?
-
- ------------------------------------------------------------------------
- Dan White
- ------------------------------------------------------------------------
- "Sometimes I think the surest sign that intelligent life exists
- elsewhere in the universe is that none of it has tried to contact us."
- Calvin (Bill Waterson)
-